﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using Quote2015;
using Trade2015;

namespace data_server
{
	class Program
	{
		static void Main(string[] args)
		{
			if (!File.Exists("TradingTime.xml"))
			{
				Console.WriteLine("没找到 TradingTime.xml 文件!");
			}
			/*
			 * 模拟,ctp|1017|tcp://ctpmn1-front1.citicsf.com:51205|tcp://ctpmn1-front1.citicsf.com:51213
银河仿真,ctp|1010|tcp://124.207.185.88:41205|tcp://124.207.185.88:41213
外汇仿真,femas|2713|tcp://117.184.207.111:7036|tcp://117.184.207.111:7230
飞创,xSpeed|galaxy|tcp://203.187.171.250:10910|tcp://203.187.171.250:10915
银河电信-二,ctp|4040|tcp://yhctp-front1.yhqh.com:41205|tcp://yhzx-front1.yhqh.com:41213
			 */
			//string svr = "ctp|1017|tcp://ctpmn1-front1.citicsf.com:51205|tcp://ctpmn1-front1.citicsf.com:51213";//模拟

			if (args.Length < 2)
			{
				Console.WriteLine(@"params: server,tickpath,logintime,logouttime
ctp|4040|tcp://yhctp-front1.yhqh.com:41205|tcp://yhzx-front1.yhqh.com:41213  C:\  08:30:00,20:30:00 15:30:00,03:00:00");
				Console.ReadLine();
				Environment.Exit(0);
			}
			string svr = args[0];
			string path = args[1];
			string inTime = args[2];
			string outTime = args[3];

			//string svr = "ctp|66666|tcp://ctpfz1-front1.citicsf.com:51205|tcp://ctpfz1-front1.citicsf.com:51213"; //仿真

			Data d = new Data(inTime, outTime);
			R:
			Console.WriteLine("请输入帐号:");
			string user = Console.ReadLine();
			Console.WriteLine("请输入密码:");
			string pwd = Console.ReadLine();

			if (!d.Init(svr, user, pwd, path))
				goto R;


			while (Console.Read() != 'q')
				;
		}

	}
	class TradeTimeInfo
	{
		/// <summary>
		/// 交易时间序列(分钟)
		/// </summary>
		public readonly List<string> Times = new List<string>();
		/// <summary>
		/// 结束时间(小节&收盘)
		/// </summary>
		public readonly List<string> EndTimes = new List<string>();
		/// <summary>
		/// 开盘前竞价时间
		/// </summary>
		public string MatchTime = string.Empty;
		/// <summary>
		/// 收盘时间
		/// </summary>
		public string CloseTime = string.Empty;
	}
}
